<?php
class Analisa extends Controller{
	
	function analisa(){
		parent::Controller();
		$this->load->model('analisa_model');
		$this->load->model('bobot_model');
	}
	
	var $title = 'Analisa';
	var $batas = 10;
	
	function upload(){
		$this->ana_off();
		$data['title'] = $this->title;
		$data['h2_title'] = 'Analisa';
		$data['main'] = 'analisa/analisa_awal_file';
		$data['action'] = site_url('bobot/addpros');
		$data['link'] = array('link_form' => anchor('analisa/form','halaman isi form',array('class' => 'back')));
		$this->load->view('base', $data);
	}
	
	function form(){
		$this->ana_off();
		$data['title'] = $this->title;
		$data['h2_title'] = 'Analisa';
		$data['main'] = 'analisa/analisa_awal_form';
		$data['action'] = site_url('analisa/pilih_periode');
		//$data['link'] = array('link_form' => anchor('analisa/upload','halaman upload',array('class' => 'back')));
		$this->load->view('base', $data);
	}
	
	function pilih_periode(){
		$data['title'] = $this->title;
		$data['h2_title'] = 'Pilih Awal Periode';
		$data['main'] = 'analisa/Jpl_periode';
		
		//ambil periode
		$this->form_validation->set_rules('periode','Periode','required');
		$per = $this->input->post('periode');
		if ($this->form_validation->run() == TRUE){
			if ($per == 1){
				$data['pilihper'] = 'analisa/Awal1';
				$this->session->set_userdata('per',1);
				$this->session->set_userdata('n_tabel','periode_1bln');
				$this->session->set_userdata('jp_max',12);
				$this->session->set_userdata('n_kolom','1bulan');
			}
			if ($per == 3){
				$data['pilihper'] = 'analisa/Awal3';
				$this->session->set_userdata('per',1);
				$this->session->set_userdata('n_tabel','periode_3bln');
				$this->session->set_userdata('jp_max',4);
				$this->session->set_userdata('n_kolom','3bulan');
			}
			if ($per == 6){
				$data['pilihper'] = 'analisa/Awal6';
				$this->session->set_userdata('per',1);
				$this->session->set_userdata('n_tabel','periode_6bln');
				$this->session->set_userdata('jp_max',2);
				$this->session->set_userdata('n_kolom','6bulan');
			}
			if ($per == 12){
				$data['pilihper'] = 'analisa/Awal12';
				$this->session->set_userdata('per',2);
				$this->session->set_userdata('n_tabel','periode_12bln');
			}
			$this->session->set_userdata('analisa',TRUE);
		}
		else {
			redirect('analisa/form');
		}
		$data['action'] = site_url('analisa/proteksi');
		$data['link'] = array('link_back' => anchor('analisa/ana_off1','kembali',array('class' => 'back','onclick' => "return confirm('Apa Anda yakin ingin membatalkan analisa?')")));
		$this->load->view('base', $data);
	}
	
	function proteksi(){
		//ambil pilih periode
		$per = $this->session->userdata('per');
		if($per == 2){
			$this->form_validation->set_rules('jumlahp','Jumlah Periode','required');
			$this->form_validation->set_rules('tahun','Tahun','required');
		}
		else{
			$this->form_validation->set_rules('jumlahp','Jumlah Periode','required');
			$this->form_validation->set_rules('awalp','Awal Periode','required');
			$this->form_validation->set_rules('tahun','Tahun','required');
		}
		
		if($this->form_validation->run() == TRUE){
			if($per == 2){
				$jlp_periode = $this->input->post('jumlahp');
				$tahun = $this->input->post('tahun');
				for($i=1; $i<=$jlp_periode; $i++){
					$peri[$i] = $tahun;
					$tahun++;
				}
				if($jlp_periode < 5){
					for($j=$jlp_periode+1; $j<=5; $j++){
						$peri[$j] = '';
					}
				}
			}
			else{
				$jlp_periode = $this->input->post('jumlahp');
				$awal = $this->input->post('awalp');
				$tahun = $this->input->post('tahun');
				$jp_max = $this->session->userdata('jp_max');
				$n_kolom = $this->session->userdata('n_kolom');
				for($i=1; $i<=$jlp_periode; $i++){
					if($awal > $jp_max){
						$tahun++;
						$awal = 1;
					}
					$peri[$i] = $this->analisa_model->select_per($n_kolom,$awal).' '.$tahun;
					$awal = $awal+1;
				}
				if($jlp_periode < 5){
					for($j=$jlp_periode+1; $j<=5; $j++){
						$peri[$j] = '';
					}
				}
				
			}
		}
		else{
			redirect('analisa/pilih_periode');
		}
		
		//simpan nama periode
		$this->session->unset_userdata('per');
		$this->session->unset_userdata('jp_max');
		$this->session->unset_userdata('n_kolom');
		$simper = array('p1' => $peri[1],
					'p2' => $peri[2],
					'p3' => $peri[3],
					'p4' => $peri[4],
					'p5' => $peri[5],
					'jml_per' => $jlp_periode);
		$this->session->set_userdata($simper);
		
		$data['title'] = $this->title;
		$data['h2_title'] = 'Form Perhitungan 1';
		$data['main'] = 'analisa/proteksi';
		
		//set nama periode
		$data['p1'] = $this->session->userdata('p1');
		$data['p2'] = $this->session->userdata('p2');
		$data['p3'] = $this->session->userdata('p3');
		$data['p4'] = $this->session->userdata('p4');
		$data['p5'] = $this->session->userdata('p5');
		
		$data['action'] = site_url('analisa/proteksi1');
		$data['submit'] = '<input type="submit" name="submit" id="reset" value=" Kalkulasi " />';
		
		$data['link'] = array('link_back' => anchor('analisa/ana_off1','kembali',array('class' => 'back','onclick' => "return confirm('Apa Anda yakin ingin membatalkan analisa?')")));
		$this->load->view('base', $data);
		
	}
	
	function proteksi1(){
		$data['title'] = $this->title;
		$data['h2_title'] = 'Form Perhitungan 1';
		$data['main'] = 'analisa/proteksi';
		$data['periode'] = 'analisa/periode_p';
		
		//set nama periode
		$data['p1'] = $this->session->userdata('p1');
		$data['p2'] = $this->session->userdata('p2');
		$data['p3'] = $this->session->userdata('p3');
		$data['p4'] = $this->session->userdata('p4');
		$data['p5'] = $this->session->userdata('p5');
		
		//set Hasil Penjumlahan
		$a[1] = $this->input->post('dpk1');
		$a[2] = $this->input->post('dpk2');
		$a[3] = $this->input->post('dpk3');
		$a[4] = $this->input->post('dpk4');
		$a[5] = $this->input->post('dpk5');
		
		$data['dpk1'] = $a[1];
		$data['dpk2'] = $a[2];
		$data['dpk3'] = $a[3];
		$data['dpk4'] = $a[4];
		$data['dpk5'] = $a[5];
		
		$b[1] = $this->input->post('kl1');
		$b[2] = $this->input->post('kl2');
		$b[3] = $this->input->post('kl3');
		$b[4] = $this->input->post('kl4');
		$b[5] = $this->input->post('kl5');
		
		$data['kl1'] = $b[1];
		$data['kl2'] = $b[2];
		$data['kl3'] = $b[3];
		$data['kl4'] = $b[4];
		$data['kl5'] = $b[5];
		
		$c[1] = $this->input->post('d1');
		$c[2] = $this->input->post('d2');
		$c[3] = $this->input->post('d3');
		$c[4] = $this->input->post('d4');
		$c[5] = $this->input->post('d5');
		
		$data['d1'] = $c[1];
		$data['d2'] = $c[2];
		$data['d3'] = $c[3];
		$data['d4'] = $c[4];
		$data['d5'] = $c[5];
		
		$d[1] = $this->input->post('m1');
		$d[2] = $this->input->post('m2');
		$d[3] = $this->input->post('m3');
		$d[4] = $this->input->post('m4');
		$d[5] = $this->input->post('m5');
		
		$data['m1'] = $d[1];
		$data['m2'] = $d[2];
		$data['m3'] = $d[3];
		$data['m4'] = $d[4];
		$data['m5'] = $d[5];
		
		$e[1] = $this->input->post('dpk11');
		$e[2] = $this->input->post('dpk12');
		$e[3] = $this->input->post('dpk13');
		$e[4] = $this->input->post('dpk14');
		$e[5] = $this->input->post('dpk15');
		
		$data['dpk11'] = $e[1];
		$data['dpk12'] = $e[2];
		$data['dpk13'] = $e[3];
		$data['dpk14'] = $e[4];
		$data['dpk15'] = $e[5];
		
		$f[1] = $this->input->post('kl11');
		$f[2] = $this->input->post('kl12');
		$f[3] = $this->input->post('kl13');
		$f[4] = $this->input->post('kl14');
		$f[5] = $this->input->post('kl15');
		
		$data['kl11'] = $f[1];
		$data['kl12'] = $f[2];
		$data['kl13'] = $f[3];
		$data['kl14'] = $f[4];
		$data['kl15'] = $f[5];
		
		$g[1] = $this->input->post('d11');
		$g[2] = $this->input->post('d12');
		$g[3] = $this->input->post('d13');
		$g[4] = $this->input->post('d14');
		$g[5] = $this->input->post('d15');
		
		$data['d11'] = $g[1];
		$data['d12'] = $g[2];
		$data['d13'] = $g[3];
		$data['d14'] = $g[4];
		$data['d15'] = $g[5];
		
		$h[1] = $this->input->post('m11');
		$h[2] = $this->input->post('m12');
		$h[3] = $this->input->post('m13');
		$h[4] = $this->input->post('m14');
		$h[5] = $this->input->post('m15');
		
		$data['m11'] = $h[1];
		$data['m12'] = $h[2];
		$data['m13'] = $h[3];
		$data['m14'] = $h[4];
		$data['m15'] = $h[5];
		
		$data['dck1'] = $this->input->post('dck1');
		$data['dck2'] = $this->input->post('dck2');
		$data['dck3'] = $this->input->post('dck3');
		$data['dck4'] = $this->input->post('dck4');
		$data['dck5'] = $this->input->post('dck5');
		
		$data['dck11'] = $this->input->post('dck11');
		$data['dck12'] = $this->input->post('dck12');
		$data['dck13'] = $this->input->post('dck13');
		$data['dck14'] = $this->input->post('dck14');
		$data['dck15'] = $this->input->post('dck15');
		
		$jml_per = $this->session->userdata('jml_per');
		for($z=1; $z<=$jml_per; $z++){
			$tp[$z] = $a[$z] + $b[$z] + $c[$z] + $d[$z];
			$tp1[$z] = $e[$z] + $f[$z] + $g[$z] + $h[$z];
		}
		if($jml_per < 5){
			for($z=$jml_per+1; $z<=5; $z++){
				$tp[$z] = '';
				$tp1[$z] = '';
			}
		}
		
		//simpan hasil di session
		$simper = array('tp1' => $tp[1],
					'tp2' => $tp[2],
					'tp3' => $tp[3],
					'tp4' => $tp[4],
					'tp5' => $tp[5],
					'tp11' => $tp1[1],
					'tp12' => $tp1[2],
					'tp13' => $tp1[3],
					'tp14' => $tp1[4],
					'tp15' => $tp1[5]);
		$this->session->set_userdata($simper);
		
		$data['tp1'] = $tp[1];
		$data['tp2'] = $tp[2];
		$data['tp3'] = $tp[3];
		$data['tp4'] = $tp[4];
		$data['tp5'] = $tp[5];
		
		$data['tp11'] = $tp1[1];
		$data['tp12'] = $tp1[2];
		$data['tp13'] = $tp1[3];
		$data['tp14'] = $tp1[4];
		$data['tp15'] = $tp1[5];
		
		//akhir set hasil penjumlahan
		
		$data['action'] = site_url('analisa/efektif');
		$data['submit'] = '<input type="submit" name="submit" id="reset" value=" Proses " />';
		
		$data['link'] = array('link_back' => anchor('analisa/ana_off1','kembali',array('class' => 'back','onclick' => "return confirm('Apa Anda yakin ingin membatalkan analisa?')")));
		$this->load->view('base', $data);
	}
	
	function efektif(){
		//ambil data proteksi
		$a[1] = $this->input->post('dck1');
		$a[2] = $this->input->post('dck2');
		$a[3] = $this->input->post('dck3');
		$a[4] = $this->input->post('dck4');
		$a[5] = $this->input->post('dck5');
		
		$b[1] = $this->session->userdata('tp1');
		$b[2] = $this->session->userdata('tp2');
		$b[3] = $this->session->userdata('tp3');
		$b[4] = $this->session->userdata('tp4');
		$b[5] = $this->session->userdata('tp5');
		
		$c[1] = $this->session->userdata('tp11');
		$c[2] = $this->session->userdata('tp12');
		$c[3] = $this->session->userdata('tp13');
		$c[4] = $this->session->userdata('tp14');
		$c[5] = $this->session->userdata('tp15');
		
		$d[1] = $this->input->post('dck11');
		$d[2] = $this->input->post('dck12');
		$d[3] = $this->input->post('dck13');
		$d[4] = $this->input->post('dck14');
		$d[5] = $this->input->post('dck15');
		
		//hitung proteksi
		$n_tabel = 'simpan_semen';
		$jml_per = $this->session->userdata('jml_per');
		for($i=1; $i<=$jml_per; $i++){
			$p1 = $this->analisa_model->hitung_p1($a[$i], $b[$i]);
			$p2 = $this->analisa_model->hitung_p2($d[$i], $c[$i]);
			$sim = array('P1' => $p1, 'P2' => $p2);
			$this->analisa_model->simpan($n_tabel,$sim);
			$IDper[$i] = $this->analisa_model->get_max();
		}
		if($jml_per < 5){
			for($j=$jml_per+1; $j<=5; $j++){
				$IDper[$j] = 0;
			}
		}
		
		//hapus session tp11
		$simper = array('tp1' => '',
					'tp2' => '',
					'tp3' => '',
					'tp4' => '',
					'tp5' => '',
					'tp11' => '',
					'tp12' => '',
					'tp13' => '',
					'tp14' => '',
					'tp15' => '');
		$this->session->unset_userdata($simper);
		
		//simpan id simpan_semen
		$simper1 = array('id_p1' => $IDper[1],
					'id_p2' => $IDper[2],
					'id_p3' => $IDper[3],
					'id_p4' => $IDper[4],
					'id_p5' => $IDper[5]);
		$this->session->set_userdata($simper1);
		
		//set nama periode
		$data['p1'] = $this->session->userdata('p1');
		$data['p2'] = $this->session->userdata('p2');
		$data['p3'] = $this->session->userdata('p3');
		$data['p4'] = $this->session->userdata('p4');
		$data['p5'] = $this->session->userdata('p5');
		
		$data['title'] = $this->title;
		$data['h2_title'] = 'Form Perhitungan 2';
		$data['main'] = 'analisa/efektif';
		$data['action'] = site_url('analisa/aset');
		$data['link'] = array('link_back' => anchor('analisa/ana_off1','kembali',array('class' => 'back','onclick' => "return confirm('Apa Anda yakin ingin membatalkan analisa?')")));
		$this->load->view('base',$data);
	}
	
	function aset(){
		//ambil data efektif
		$a[1] = $this->input->post('tpb1');
		$a[2] = $this->input->post('tpb2');
		$a[3] = $this->input->post('tpb3');
		$a[4] = $this->input->post('tpb4');
		$a[5] = $this->input->post('tpb5');
		
		$b[1] = $this->input->post('tsn1');
		$b[2] = $this->input->post('tsn2');
		$b[3] = $this->input->post('tsn3');
		$b[4] = $this->input->post('tsn4');
		$b[5] = $this->input->post('tsn5');
		
		$c[1] = $this->input->post('tjp1');
		$c[2] = $this->input->post('tjp2');
		$c[3] = $this->input->post('tjp3');
		$c[4] = $this->input->post('tjp4');
		$c[5] = $this->input->post('tjp5');
		
		$d[1] = $this->input->post('ssa1');
		$d[2] = $this->input->post('ssa2');
		$d[3] = $this->input->post('ssa3');
		$d[4] = $this->input->post('ssa4');
		$d[5] = $this->input->post('ssa5');
		
		$e[1] = $this->input->post('tml1');
		$e[2] = $this->input->post('tml2');
		$e[3] = $this->input->post('tml3');
		$e[4] = $this->input->post('tml4');
		$e[5] = $this->input->post('tml5');
		
		$f[1] = $this->input->post('ta1');
		$f[2] = $this->input->post('ta2');
		$f[3] = $this->input->post('ta3');
		$f[4] = $this->input->post('ta4');
		$f[5] = $this->input->post('ta5');
		
		//ambil id simpan_semen
		$id_p[1] = $this->session->userdata('id_p1');
		$id_p[2] = $this->session->userdata('id_p2');
		$id_p[3] = $this->session->userdata('id_p3');
		$id_p[4] = $this->session->userdata('id_p4');
		$id_p[5] = $this->session->userdata('id_p5');
		
		//hitung efektif
		$jml_per = $this->session->userdata('jml_per');
		for($i=1; $i<=$jml_per; $i++){
			$e1 = $this->analisa_model->hitung_e1($a[$i],$f[$i]);
			$e2 = $this->analisa_model->hitung_e2($b[$i],$f[$i]);
			$e3 = $this->analisa_model->hitung_e3($c[$i],$f[$i]);
			$e4 = $this->analisa_model->hitung_e4($d[$i],$f[$i]);
			$e5 = $this->analisa_model->hitung_e5($e[$i],$f[$i]);
			$sim = array('E1' => $e1, 'E2' => $e2, 'E3' => $e3, 'E4' => $e4, 'E5' => $e5);
			$this->analisa_model->update($id_p[$i],$sim);
		}
		
		$data['title'] = $this->title;
		$data['h2_title'] = 'Form Perhitungan 3';
		$data['main'] = 'analisa/aset';
		
		//set nama periode
		$data['p1'] = $this->session->userdata('p1');
		$data['p2'] = $this->session->userdata('p2');
		$data['p3'] = $this->session->userdata('p3');
		$data['p4'] = $this->session->userdata('p4');
		$data['p5'] = $this->session->userdata('p5');
		
		$data['action'] = site_url('analisa/return1');
		$data['link'] = array('link_back' => anchor('analisa/ana_off1','kembali',array('class' => 'back','onclick' => "return confirm('Apa Anda yakin ingin membatalkan analisa?')")));
		$this->load->view('base',$data);
	}
	
	function return1(){
		//ambil data aset
		$a[1] = $this->input->post('pmp1');
		$a[2] = $this->input->post('pmp2');
		$a[3] = $this->input->post('pmp3');
		$a[4] = $this->input->post('pmp4');
		$a[5] = $this->input->post('pmp5');
		
		$b[1] = $this->input->post('pb1');
		$b[2] = $this->input->post('pb2');
		$b[3] = $this->input->post('pb3');
		$b[4] = $this->input->post('pb4');
		$b[5] = $this->input->post('pb5');
		
		$c[1] = $this->input->post('atm1');
		$c[2] = $this->input->post('atm2');
		$c[3] = $this->input->post('atm3');
		$c[4] = $this->input->post('atm4');
		$c[5] = $this->input->post('atm5');
		
		$d[1] = $this->input->post('ta1');
		$d[2] = $this->input->post('ta2');
		$d[3] = $this->input->post('ta3');
		$d[4] = $this->input->post('ta4');
		$d[5] = $this->input->post('ta5');
		
		$e[1] = $this->input->post('mlb1');
		$e[2] = $this->input->post('mlb2');
		$e[3] = $this->input->post('mlb3');
		$e[4] = $this->input->post('mlb4');
		$e[5] = $this->input->post('mlb5');
		
		$f[1] = $this->input->post('mt1');
		$f[2] = $this->input->post('mt2');
		$f[3] = $this->input->post('mt3');
		$f[4] = $this->input->post('mt4');
		$f[5] = $this->input->post('mt5');
		
		$g[1] = $this->input->post('htt1');
		$g[2] = $this->input->post('htt2');
		$g[3] = $this->input->post('htt3');
		$g[4] = $this->input->post('htt4');
		$g[5] = $this->input->post('htt5');
		
		//ambil id simpan_semen
		$id_p[1] = $this->session->userdata('id_p1');
		$id_p[2] = $this->session->userdata('id_p2');
		$id_p[3] = $this->session->userdata('id_p3');
		$id_p[4] = $this->session->userdata('id_p4');
		$id_p[5] = $this->session->userdata('id_p5');
		
		//hitung aset
		$jml_per = $this->session->userdata('jml_per');
		for($i=1; $i<=$jml_per; $i++){
			$a1 = $this->analisa_model->hitung_a1($a[$i],$b[$i]);
			$a2 = $this->analisa_model->hitung_a2($c[$i],$d[$i]);
			$a3 = $this->analisa_model->hitung_a3($e[$i],$f[$i],$g[$i],$c[$i]);
			$sim = array('A1' => $a1, 'A2' => $a2, 'A3' => $a3);
			$this->analisa_model->update($id_p[$i],$sim);
		}
		
		$data['title'] = $this->title;
		$data['h2_title'] = 'Form Perhitungan 4';
		$data['main'] = 'analisa/return';
		
		//set nama periode
		$data['p1'] = $this->session->userdata('p1');
		$data['p2'] = $this->session->userdata('p2');
		$data['p3'] = $this->session->userdata('p3');
		$data['p4'] = $this->session->userdata('p4');
		$data['p5'] = $this->session->userdata('p5');
		
		$data['action'] = site_url('analisa/likuid');
		$data['link'] = array('link_back' => anchor('analisa/ana_off1','kembali',array('class' => 'back','onclick' => "return confirm('Apa Anda yakin ingin membatalkan analisa?')")));
		$this->load->view('base',$data);
	}
	
	function likuid(){
		//ambil data return
		$a[1] = $this->input->post('tbo1');
		$a[2] = $this->input->post('tbo2');
		$a[3] = $this->input->post('tbo3');
		$a[4] = $this->input->post('tbo4');
		$a[5] = $this->input->post('tbo5');
		
		$b[1] = $this->input->post('tpo1');
		$b[2] = $this->input->post('tpo2');
		$b[3] = $this->input->post('tpo3');
		$b[4] = $this->input->post('tpo4');
		$b[5] = $this->input->post('tpo5');
		
		$c[1] = $this->input->post('lb1');
		$c[2] = $this->input->post('lb2');
		$c[3] = $this->input->post('lb3');
		$c[4] = $this->input->post('lb4');
		$c[5] = $this->input->post('lb5');
		
		$d[1] = $this->input->post('ms1');
		$d[2] = $this->input->post('ms2');
		$d[3] = $this->input->post('ms3');
		$d[4] = $this->input->post('ms4');
		$d[5] = $this->input->post('ms5');
		
		$e[1] = $this->input->post('tatb1');
		$e[2] = $this->input->post('tatb2');
		$e[3] = $this->input->post('tatb3');
		$e[4] = $this->input->post('tatb4');
		$e[5] = $this->input->post('tatb5');
		
		//ambil id simpan_semen
		$id_p[1] = $this->session->userdata('id_p1');
		$id_p[2] = $this->session->userdata('id_p2');
		$id_p[3] = $this->session->userdata('id_p3');
		$id_p[4] = $this->session->userdata('id_p4');
		$id_p[5] = $this->session->userdata('id_p5');
		
		//hitung return
		$jml_per = $this->session->userdata('jml_per');
		for($i=1; $i<=$jml_per; $i++){
			$r1 = $this->analisa_model->hitung_r1($a[$i],$b[$i]);
			$r2 = $this->analisa_model->hitung_r2($c[$i],$d[$i]);
			$r3 = $this->analisa_model->hitung_r3($c[$i],$e[$i]);
			$sim = array('R1' => $r1, 'R2' => $r2, 'R3' => $r3);
			$this->analisa_model->update($id_p[$i],$sim);
		}
		
		$data['title'] = $this->title;
		$data['h2_title'] = 'Form Perhitungan 5';
		$data['main'] = 'analisa/likuid';
		
		//set nama periode
		$data['p1'] = $this->session->userdata('p1');
		$data['p2'] = $this->session->userdata('p2');
		$data['p3'] = $this->session->userdata('p3');
		$data['p4'] = $this->session->userdata('p4');
		$data['p5'] = $this->session->userdata('p5');
		
		$data['action'] = site_url('analisa/sign');
		$data['link'] = array('link_back' => anchor('analisa/ana_off1','kembali',array('class' => 'back','onclick' => "return confirm('Apa Anda yakin ingin membatalkan analisa?')")));
		$this->load->view('base',$data);
	}
	
	function sign(){
		//ambil data likuid
		$a[1] = $this->input->post('kas1');
		$a[2] = $this->input->post('kas2');
		$a[3] = $this->input->post('kas3');
		$a[4] = $this->input->post('kas4');
		$a[5] = $this->input->post('kas5');
		
		$b[1] = $this->input->post('aba1');
		$b[2] = $this->input->post('aba2');
		$b[3] = $this->input->post('aba3');
		$b[4] = $this->input->post('aba4');
		$b[5] = $this->input->post('aba5');
		
		$c[1] = $this->input->post('abp1');
		$c[2] = $this->input->post('abp2');
		$c[3] = $this->input->post('abp3');
		$c[4] = $this->input->post('abp4');
		$c[5] = $this->input->post('abp5');
		
		$d[1] = $this->input->post('kyd1');
		$d[2] = $this->input->post('kyd2');
		$d[3] = $this->input->post('kyd3');
		$d[4] = $this->input->post('kyd4');
		$d[5] = $this->input->post('kyd5');
		
		$e[1] = $this->input->post('sns1');
		$e[2] = $this->input->post('sns2');
		$e[3] = $this->input->post('sns3');
		$e[4] = $this->input->post('sns4');
		$e[5] = $this->input->post('sns5');
		
		$f[1] = $this->input->post('ltm1');
		$f[2] = $this->input->post('ltm2');
		$f[3] = $this->input->post('ltm3');
		$f[4] = $this->input->post('ltm4');
		$f[5] = $this->input->post('ltm5');
		
		$g[1] = $this->input->post('ta1');
		$g[2] = $this->input->post('ta2');
		$g[3] = $this->input->post('ta3');
		$g[4] = $this->input->post('ta4');
		$g[5] = $this->input->post('ta5');
		
		//ambil id simpan_semen
		$id_p[1] = $this->session->userdata('id_p1');
		$id_p[2] = $this->session->userdata('id_p2');
		$id_p[3] = $this->session->userdata('id_p3');
		$id_p[4] = $this->session->userdata('id_p4');
		$id_p[5] = $this->session->userdata('id_p5');
		
		//hitung likuid
		$jml_per = $this->session->userdata('jml_per');
		for($i=1; $i<=$jml_per; $i++){
			$l1 = $this->analisa_model->hitung_l1($a[$i],$b[$i],$c[$i],$e[$i]);
			$l2 = $this->analisa_model->hitung_l2($d[$i],$e[$i]);
			$l3 = $this->analisa_model->hitung_l3($f[$i],$g[$i]);
			$sim = array('L1' => $l1, 'L2' => $l2, 'L3' => $l3);
			$this->analisa_model->update($id_p[$i],$sim);
		}
		
		$data['title'] = $this->title;
		$data['h2_title'] = 'Form Perhitungan 6';
		$data['main'] = 'analisa/sign';
		
		//set nama periode
		$data['p1'] = $this->session->userdata('p1');
		$data['p2'] = $this->session->userdata('p2');
		$data['p3'] = $this->session->userdata('p3');
		$data['p4'] = $this->session->userdata('p4');
		$data['p5'] = $this->session->userdata('p5');
		
		$data['action'] = site_url('analisa/resume');
		$data['link'] = array('link_back' => anchor('analisa/ana_off1','kembali',array('class' => 'back','onclick' => "return confirm('Apa Anda yakin ingin membatalkan analisa?')")));
		$this->load->view('base',$data);
	}
	
	function resume(){
		//ambil data sign
		$a[1] = $this->input->post('ptb1');
		$a[2] = $this->input->post('ptb2');
		$a[3] = $this->input->post('ptb3');
		$a[4] = $this->input->post('ptb4');
		$a[5] = $this->input->post('ptb5');
		
		$b[1] = $this->input->post('ptl1');
		$b[2] = $this->input->post('ptl2');
		$b[3] = $this->input->post('ptl3');
		$b[4] = $this->input->post('ptl4');
		$b[5] = $this->input->post('ptl5');
		
		$c[1] = $this->input->post('stb1');
		$c[2] = $this->input->post('stb2');
		$c[3] = $this->input->post('stb3');
		$c[4] = $this->input->post('stb4');
		$c[5] = $this->input->post('stb5');
		
		$d[1] = $this->input->post('stl1');
		$d[2] = $this->input->post('stl2');
		$d[3] = $this->input->post('stl3');
		$d[4] = $this->input->post('stl4');
		$d[5] = $this->input->post('stl5');
		
		$e[1] = $this->input->post('ctb1');
		$e[2] = $this->input->post('ctb2');
		$e[3] = $this->input->post('ctb3');
		$e[4] = $this->input->post('ctb4');
		$e[5] = $this->input->post('ctb5');
		
		$f[1] = $this->input->post('ctl1');
		$f[2] = $this->input->post('ctl2');
		$f[3] = $this->input->post('ctl3');
		$f[4] = $this->input->post('ctl4');
		$f[5] = $this->input->post('ctl5');
		
		$g[1] = $this->input->post('mtb1');
		$g[2] = $this->input->post('mtb2');
		$g[3] = $this->input->post('mtb3');
		$g[4] = $this->input->post('mtb4');
		$g[5] = $this->input->post('mtb5');
		
		$h[1] = $this->input->post('mtl1');
		$h[2] = $this->input->post('mtl2');
		$h[3] = $this->input->post('mtl3');
		$h[4] = $this->input->post('mtl4');
		$h[5] = $this->input->post('mtl5');
		
		$i[1] = $this->input->post('otb1');
		$i[2] = $this->input->post('otb2');
		$i[3] = $this->input->post('otb3');
		$i[4] = $this->input->post('otb4');
		$i[5] = $this->input->post('otb5');
		
		$j[1] = $this->input->post('otl1');
		$j[2] = $this->input->post('otl2');
		$j[3] = $this->input->post('otl3');
		$j[4] = $this->input->post('otl4');
		$j[5] = $this->input->post('otl5');
		
		$k[1] = $this->input->post('atb1');
		$k[2] = $this->input->post('atb2');
		$k[3] = $this->input->post('atb3');
		$k[4] = $this->input->post('atb4');
		$k[5] = $this->input->post('atb5');
		
		$l[1] = $this->input->post('atl1');
		$l[2] = $this->input->post('atl2');
		$l[3] = $this->input->post('atl3');
		$l[4] = $this->input->post('atl4');
		$l[5] = $this->input->post('atl5');
		
		$m[1] = $this->input->post('ttb1');
		$m[2] = $this->input->post('ttb2');
		$m[3] = $this->input->post('ttb3');
		$m[4] = $this->input->post('ttb4');
		$m[5] = $this->input->post('ttb5');
		
		$n[1] = $this->input->post('ttl1');
		$n[2] = $this->input->post('ttl2');
		$n[3] = $this->input->post('ttl3');
		$n[4] = $this->input->post('ttl4');
		$n[5] = $this->input->post('ttl5');
		
		//ambil id simpan_semen
		$id_p[1] = $this->session->userdata('id_p1');
		$id_p[2] = $this->session->userdata('id_p2');
		$id_p[3] = $this->session->userdata('id_p3');
		$id_p[4] = $this->session->userdata('id_p4');
		$id_p[5] = $this->session->userdata('id_p5');
		
		//hitung sign
		$jml_per = $this->session->userdata('jml_per');
		for($z=1; $z<=$jml_per; $z++){
			$s1 = $this->analisa_model->hitung_s1($a[$z], $b[$z]);
			$s2 = $this->analisa_model->hitung_s2($c[$z], $d[$z]);
			$s3 = $this->analisa_model->hitung_s3($e[$z], $f[$z]);
			$s4 = $this->analisa_model->hitung_s4($g[$z], $h[$z]);
			$s5 = $this->analisa_model->hitung_s5($i[$z], $j[$z]);
			$s6 = $this->analisa_model->hitung_s6($k[$z], $l[$z]);
			$s7 = $this->analisa_model->hitung_s7($m[$z], $n[$z]);
			$sim = array('S1' => $s1, 'S2' => $s2, 'S3' => $s3, 'S4' => $s4, 'S5' => $s5, 'S6' => $s6, 'S7' => $s7);
			$this->analisa_model->update($id_p[$z],$sim);
		}
		
		//tampilkan resume
		for($z=1; $z<=$jml_per; $z++){
			$data['pe1'][$z] = $this->analisa_model->baca_semen('P1',$id_p[$z]);
		}
		for($z=1; $z<=$jml_per; $z++){
			$data['pe2'][$z] = $this->analisa_model->baca_semen('P2',$id_p[$z]);
		}
		for($z=1; $z<=$jml_per; $z++){
			$data['e1'][$z] = $this->analisa_model->baca_semen('E1',$id_p[$z]);
		}
		for($z=1; $z<=$jml_per; $z++){
			$data['e2'][$z] = $this->analisa_model->baca_semen('E2',$id_p[$z]);
		}
		for($z=1; $z<=$jml_per; $z++){
			$data['e3'][$z] = $this->analisa_model->baca_semen('E3',$id_p[$z]);
		}
		for($z=1; $z<=$jml_per; $z++){
			$data['e4'][$z] = $this->analisa_model->baca_semen('E4',$id_p[$z]);
		}
		for($z=1; $z<=$jml_per; $z++){
			$data['e5'][$z] = $this->analisa_model->baca_semen('E5',$id_p[$z]);
		}
		for($z=1; $z<=$jml_per; $z++){
			$data['a1'][$z] = $this->analisa_model->baca_semen('A1',$id_p[$z]);
		}
		for($z=1; $z<=$jml_per; $z++){
			$data['a2'][$z] = $this->analisa_model->baca_semen('A2',$id_p[$z]);
		}
		for($z=1; $z<=$jml_per; $z++){
			$data['a3'][$z] = $this->analisa_model->baca_semen('A3',$id_p[$z]);
		}
		for($z=1; $z<=$jml_per; $z++){
			$data['r1'][$z] = $this->analisa_model->baca_semen('R1',$id_p[$z]);
		}
		for($z=1; $z<=$jml_per; $z++){
			$data['r2'][$z] = $this->analisa_model->baca_semen('R2',$id_p[$z]);
		}
		for($z=1; $z<=$jml_per; $z++){
			$data['r3'][$z] = $this->analisa_model->baca_semen('R3',$id_p[$z]);
		}
		for($z=1; $z<=$jml_per; $z++){
			$data['l1'][$z] = $this->analisa_model->baca_semen('L1',$id_p[$z]);
		}
		for($z=1; $z<=$jml_per; $z++){
			$data['l2'][$z] = $this->analisa_model->baca_semen('L2',$id_p[$z]);
		}
		for($z=1; $z<=$jml_per; $z++){
			$data['l3'][$z] = $this->analisa_model->baca_semen('L3',$id_p[$z]);
		}
		for($z=1; $z<=$jml_per; $z++){
			$data['s1'][$z] = $this->analisa_model->baca_semen('S1',$id_p[$z]);
		}
		for($z=1; $z<=$jml_per; $z++){
			$data['s2'][$z] = $this->analisa_model->baca_semen('S2',$id_p[$z]);
		}
		for($z=1; $z<=$jml_per; $z++){
			$data['s3'][$z] = $this->analisa_model->baca_semen('S3',$id_p[$z]);
		}
		for($z=1; $z<=$jml_per; $z++){
			$data['s4'][$z] = $this->analisa_model->baca_semen('S4',$id_p[$z]);
		}
		for($z=1; $z<=$jml_per; $z++){
			$data['s5'][$z] = $this->analisa_model->baca_semen('S5',$id_p[$z]);
		}
		for($z=1; $z<=$jml_per; $z++){
			$data['s6'][$z] = $this->analisa_model->baca_semen('S6',$id_p[$z]);
		}
		for($z=1; $z<=$jml_per; $z++){
			$data['s7'][$z] = $this->analisa_model->baca_semen('S7',$id_p[$z]);
		}
		
		$data['title'] = $this->title;
		$data['h2_title'] = 'Resume';
		$data['main'] = 'analisa/resume';
		
		//set nama periode
		$data['p1'] = $this->session->userdata('p1');
		$data['p2'] = $this->session->userdata('p2');
		$data['p3'] = $this->session->userdata('p3');
		$data['p4'] = $this->session->userdata('p4');
		$data['p5'] = $this->session->userdata('p5');
		
		$data['action'] = site_url('analisa/pilih');
		$data['link'] = array('link_back' => anchor('analisa/ana_off1','kembali',array('class' => 'back','onclick' => "return confirm('Apa Anda yakin ingin membatalkan analisa?')")));
		$this->load->view('base',$data);
	}
	
	function pilih(){
		$data['title'] = $this->title;
		$data['h2_title'] = 'Memilih Bobot';
		$data['main'] = 'analisa/p_bobot';
		$data['action'] = site_url('analisa/proses');
		
		//set pagination
		$config['base_url'] = site_url('bobot/get');
		$config['total_rows'] = $this->bobot_model->count_table();
		$config['per_page'] = $this->batas;
		$this->pagination->initialize($config);
		$data['pagination'] = $this->pagination->create_links();
		
		//set tabel
		$tmpl = array( 'table_open'  => '<table border="0" cellpadding="0" cellspacing="0">',
					'row_alt_start'  => '<tr class="zebra">',
					'row_alt_end'    => '</tr>');
					
		$this->table->set_template($tmpl);
		
		$this->table->set_empty('&nbsp;');
		$this->table->set_heading('','Nama','P','E','A','R','L','S');
		
		$bot = $this->bobot_model->get();
		$n = 1;
		
		foreach($bot as $row){
			$radio = '<input type="radio" name="bobot" value="'.$row->id_bobot.'" />';
			$this->table->add_row($radio,$row->nama_bobot,$row->p.' %', $row->e.' %', $row->a.' %', $row->r.' %', $row->l.' %', $row->s.' %');
		}
		$data['table'] = $this->table->generate();
		
		$data['link'] = array('link_back' => anchor('analisa/ana_off1','kembali',array('class' => 'back','onclick' => "return confirm('Apa Anda yakin ingin membatalkan analisa?')")));
		
		$this->load->view('base',$data);
	}
	
	function proses(){
		//ambil bobot
		$id_bobot = $this->input->post('bobot');
		$bot = $this->bobot_model->get_byid($id_bobot);
			$p = $bot->p;
			$e = $bot->e;
			$a = $bot->a;
			$r = $bot->r;
			$l = $bot->l;
			$s = $bot->s;
		
		//ambil id simpan_semen
		$id_p[1] = $this->session->userdata('id_p1');
		$id_p[2] = $this->session->userdata('id_p2');
		$id_p[3] = $this->session->userdata('id_p3');
		$id_p[4] = $this->session->userdata('id_p4');
		$id_p[5] = $this->session->userdata('id_p5');
		
		//perhitungan hasil akhir
		$jml_per = $this->session->userdata('jml_per');
		for($z=1; $z<=$jml_per; $z++){
			$sim = $this->analisa_model->get_arow($id_p[$z]);
			$p1 = $this->analisa_model->nilai_p1($sim->P1);
			$p2 = $this->analisa_model->nilai_p2($sim->P2);
			$e1 = $this->analisa_model->nilai_e1($sim->E1);
			$e2 = $this->analisa_model->nilai_e2($sim->E2);
			$e3 = $this->analisa_model->nilai_e3($sim->E3);
			$e4 = $this->analisa_model->nilai_e4($sim->E4);
			$e5 = $this->analisa_model->nilai_e5($sim->E5);
			$a1 = $this->analisa_model->nilai_a1($sim->A1);
			$a2 = $this->analisa_model->nilai_a2($sim->A2);
			$a3 = $this->analisa_model->nilai_a3($sim->A3);
			$r1 = $this->analisa_model->nilai_r1($sim->R1);
			$r2 = $this->analisa_model->nilai_r2($sim->R2);
			$r3 = $this->analisa_model->nilai_r3($sim->R3);
			$l1 = $this->analisa_model->nilai_l1($sim->L1);
			$l2 = $this->analisa_model->nilai_l2($sim->L2);
			$l3 = $this->analisa_model->nilai_l3($sim->L3);
			$s1 = $this->analisa_model->nilai_s1($sim->S1);
			$s2 = $this->analisa_model->nilai_s2($sim->S2);
			$s3 = $this->analisa_model->nilai_s3($sim->S3);
			$s4 = $this->analisa_model->nilai_s4($sim->S4);
			$s5 = $this->analisa_model->nilai_s5($sim->S5);
			$s6 = $this->analisa_model->nilai_s6($sim->S6);
			$s7 = $this->analisa_model->nilai_s7($sim->S7);
			
			$hp = ($p1 + $p2)/160 * $p;
			$he = ($e1 + $e2 + $e3 + $e4 +$e5)/400 * $e;
			$ha = ($a1 + $a2 + $a3)/240 * $a;
			$hr = ($r1 + $r2 + $r3)/240 * $r;
			$hl = ($l1 + $l2 + $l3)/240 * $l;
			$hs = ($s1 + $s2 + $s3 + $s4 + $s5 + $s6 + $s7)/560 * $s;
			
			$hasil = $hp + $he + $ha + $hr + $hl + $hs;
			
			$simpa = array('ID_BOBOT' => $id_bobot, 'HASIL' => $hasil);
			$this->analisa_model->update($id_p[$z],$simpa);
			
			//$data['hasil'][$z] = $sim->HASIL;
		}
		
		//tampilkan resume
		for($z=1; $z<=$jml_per; $z++){
			$data['pe1'][$z] = $this->analisa_model->baca_semen('P1',$id_p[$z]);
		}
		for($z=1; $z<=$jml_per; $z++){
			$data['pe2'][$z] = $this->analisa_model->baca_semen('P2',$id_p[$z]);
		}
		for($z=1; $z<=$jml_per; $z++){
			$data['e1'][$z] = $this->analisa_model->baca_semen('E1',$id_p[$z]);
		}
		for($z=1; $z<=$jml_per; $z++){
			$data['e2'][$z] = $this->analisa_model->baca_semen('E2',$id_p[$z]);
		}
		for($z=1; $z<=$jml_per; $z++){
			$data['e3'][$z] = $this->analisa_model->baca_semen('E3',$id_p[$z]);
		}
		for($z=1; $z<=$jml_per; $z++){
			$data['e4'][$z] = $this->analisa_model->baca_semen('E4',$id_p[$z]);
		}
		for($z=1; $z<=$jml_per; $z++){
			$data['e5'][$z] = $this->analisa_model->baca_semen('E5',$id_p[$z]);
		}
		for($z=1; $z<=$jml_per; $z++){
			$data['a1'][$z] = $this->analisa_model->baca_semen('A1',$id_p[$z]);
		}
		for($z=1; $z<=$jml_per; $z++){
			$data['a2'][$z] = $this->analisa_model->baca_semen('A2',$id_p[$z]);
		}
		for($z=1; $z<=$jml_per; $z++){
			$data['a3'][$z] = $this->analisa_model->baca_semen('A3',$id_p[$z]);
		}
		for($z=1; $z<=$jml_per; $z++){
			$data['r1'][$z] = $this->analisa_model->baca_semen('R1',$id_p[$z]);
		}
		for($z=1; $z<=$jml_per; $z++){
			$data['r2'][$z] = $this->analisa_model->baca_semen('R2',$id_p[$z]);
		}
		for($z=1; $z<=$jml_per; $z++){
			$data['r3'][$z] = $this->analisa_model->baca_semen('R3',$id_p[$z]);
		}
		for($z=1; $z<=$jml_per; $z++){
			$data['l1'][$z] = $this->analisa_model->baca_semen('L1',$id_p[$z]);
		}
		for($z=1; $z<=$jml_per; $z++){
			$data['l2'][$z] = $this->analisa_model->baca_semen('L2',$id_p[$z]);
		}
		for($z=1; $z<=$jml_per; $z++){
			$data['l3'][$z] = $this->analisa_model->baca_semen('L3',$id_p[$z]);
		}
		for($z=1; $z<=$jml_per; $z++){
			$data['s1'][$z] = $this->analisa_model->baca_semen('S1',$id_p[$z]);
		}
		for($z=1; $z<=$jml_per; $z++){
			$data['s2'][$z] = $this->analisa_model->baca_semen('S2',$id_p[$z]);
		}
		for($z=1; $z<=$jml_per; $z++){
			$data['s3'][$z] = $this->analisa_model->baca_semen('S3',$id_p[$z]);
		}
		for($z=1; $z<=$jml_per; $z++){
			$data['s4'][$z] = $this->analisa_model->baca_semen('S4',$id_p[$z]);
		}
		for($z=1; $z<=$jml_per; $z++){
			$data['s5'][$z] = $this->analisa_model->baca_semen('S5',$id_p[$z]);
		}
		for($z=1; $z<=$jml_per; $z++){
			$data['s6'][$z] = $this->analisa_model->baca_semen('S6',$id_p[$z]);
		}
		for($z=1; $z<=$jml_per; $z++){
			$data['s7'][$z] = $this->analisa_model->baca_semen('S7',$id_p[$z]);
		}
		for($z=1; $z<=$jml_per; $z++){
			$data['hasil'][$z] = $this->analisa_model->baca_semen('HASIL',$id_p[$z]);
		}
		
		//set nama periode
		$data['p1'] = $this->session->userdata('p1');
		$data['p2'] = $this->session->userdata('p2');
		$data['p3'] = $this->session->userdata('p3');
		$data['p4'] = $this->session->userdata('p4');
		$data['p5'] = $this->session->userdata('p5');
		
		$data['title'] = $this->title;
		$data['h2_title'] = 'Hasil Perhitungan';
		$data['main'] = 'analisa/hasil';
		$data['action'] = site_url('analisa/finish');
		$data['link'] = array('link_back' => anchor('analisa/ana_off1','kembali',array('class' => 'back','onclick' => "return confirm('Apa Anda yakin ingin membatalkan analisa?')")));		
		$this->load->view('base',$data);

	}
	
	function finish(){
		//ambil id simpan_semen
		$id_p[1] = $this->session->userdata('id_p1');
		$id_p[2] = $this->session->userdata('id_p2');
		$id_p[3] = $this->session->userdata('id_p3');
		$id_p[4] = $this->session->userdata('id_p4');
		$id_p[5] = $this->session->userdata('id_p5');
		
		//set nama periode
		$p[1] = $this->session->userdata('p1');
		$p[2] = $this->session->userdata('p2');
		$p[3] = $this->session->userdata('p3');
		$p[4] = $this->session->userdata('p4');
		$p[5] = $this->session->userdata('p5');
		
		//pindah ke tabel masing-masing periode
		$jml_per = $this->session->userdata('jml_per');
		$n_tabel = $this->session->userdata('n_tabel');
		$id_cab = $this->session->userdata('id_cabang');
		for($z=1; $z<=$jml_per; $z++){
			$sim = $this->analisa_model->get_arow($id_p[$z]);
			$pe1 = $this->analisa_model->nilai_p1($sim->P1);
			$pe2 = $this->analisa_model->nilai_p2($sim->P2);
			$e1 = $this->analisa_model->nilai_e1($sim->E1);
			$e2 = $this->analisa_model->nilai_e2($sim->E2);
			$e3 = $this->analisa_model->nilai_e3($sim->E3);
			$e4 = $this->analisa_model->nilai_e4($sim->E4);
			$e5 = $this->analisa_model->nilai_e5($sim->E5);
			$a1 = $this->analisa_model->nilai_a1($sim->A1);
			$a2 = $this->analisa_model->nilai_a2($sim->A2);
			$a3 = $this->analisa_model->nilai_a3($sim->A3);
			$r1 = $this->analisa_model->nilai_r1($sim->R1);
			$r2 = $this->analisa_model->nilai_r2($sim->R2);
			$r3 = $this->analisa_model->nilai_r3($sim->R3);
			$l1 = $this->analisa_model->nilai_l1($sim->L1);
			$l2 = $this->analisa_model->nilai_l2($sim->L2);
			$l3 = $this->analisa_model->nilai_l3($sim->L3);
			$s1 = $this->analisa_model->nilai_s1($sim->S1);
			$s2 = $this->analisa_model->nilai_s2($sim->S2);
			$s3 = $this->analisa_model->nilai_s3($sim->S3);
			$s4 = $this->analisa_model->nilai_s4($sim->S4);
			$s5 = $this->analisa_model->nilai_s5($sim->S5);
			$s6 = $this->analisa_model->nilai_s6($sim->S6);
			$s7 = $this->analisa_model->nilai_s7($sim->S7);
			$id_bobot = $sim->ID_BOBOT;
			$hasil = $sim->HASIL;
			
			$simpan = array('ID_CABANG' => $id_cab,
							'ID_BOBOT' => $id_bobot,
							'HASIL' => $hasil,
							'WAKTU' => date("Y-m-d H:i:s"),
							'Periode' => $p[$z],
							'P1' => $sim->P1,
							'P2' => $sim->P2,
							'E1' => $sim->E1,
							'E2' => $sim->E2,
							'E3' => $sim->E3,
							'E4' => $sim->E4,
							'E5' => $sim->E5,
							'A1' => $sim->A1,
							'A2' => $sim->A2,
							'A3' => $sim->A3,
							'R1' => $sim->R1,
							'R2' => $sim->R2,
							'R3' => $sim->R3,
							'L1' => $sim->L1,
							'L2' => $sim->L2,
							'L3' => $sim->L3,
							'S1' => $sim->S1,
							'S2' => $sim->S2,
							'S3' => $sim->S3,
							'S4' => $sim->S4,
							'S5' => $sim->S5,
							'S6' => $sim->S6,
							'S7' => $sim->S7);
			$this->analisa_model->simpan($n_tabel,$simpan);
		}
		$this->ana_off();
		$this->form();
	}
	
	function ana_off(){
		$this->analisa_model->truncate();
		$an_des = array('id_p1' => '',
						'id_p2' => '',
						'id_p3' => '',
						'id_p4' => '',
						'id_p5' => '',
						'p1' => '',
						'p2' => '',
						'p3' => '',
						'p4' => '',
						'p5' => '',
						'jml_per' => '',
						'n_tabel' => '');
		$this->session->unset_userdata($an_des);
		$this->session->set_userdata('analisa', FALSE);
	}
	
	function ana_off1(){//dilempar ke analisa/form
		$this->analisa_model->truncate();
		$an_des = array('id_p1' => '',
						'id_p2' => '',
						'id_p3' => '',
						'id_p4' => '',
						'id_p5' => '',
						'p1' => '',
						'p2' => '',
						'p3' => '',
						'p4' => '',
						'p5' => '',
						'jml_per' => '',
						'n_tabel' => '');
		$this->session->unset_userdata($an_des);
		$this->session->set_userdata('analisa', FALSE);
		$this->form();
	}
}
?>